package com.deep.deepenterprise.api.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

/**
 * @author xyz
 * @version 1.0
 * @title DrGlobalCORSConfig
 * @description
 * @create 2024/5/30 13:22
 */
@Configuration
public class DrGlobalCORSConfig {
    @Bean
    @Profile("test")
    public CorsFilter drCorsFilter() {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        CorsConfiguration drConfig = new CorsConfiguration();
        drConfig.addAllowedOrigin("*");
        drConfig.addAllowedHeader("*");
        drConfig.addAllowedMethod("*");
        source.registerCorsConfiguration("/**", drConfig);
        return new CorsFilter(source);
    }
}
